<?php
$root = realpath($_SERVER["DOCUMENT_ROOT"]) . "/SmartTuition/SmartTuition.Model"; 
// includes
require_once("$root/Abstraction/IRepository.php");
require_once("$root/Concrete/DBContext.php");
require_once("$root/Models/Document.php");

class DocumentRepository implements IRepository
{
    public function GetAll() {
        return DBContext::Instance()->GetFromTable("document","*");
    }
    public function GetById($id) {
        return DBContext::Instance()->GetFromTable("document","*", "where DocumentID=$id");
    }
    public function DeleteById($id) {
        DBContext::Instance()->DeleteFromTable("document","DocumentID",$id);
    }
    public function Delete(EntityWithID $ent) {
        DBContext::Instance()->DeleteFromTable("document","DocumentID", $ent->getId());
    }
    public function Update(EntityWithID $entity) {
        DBContext::Instance()->UpdateTableRecord("document", $entity->getColumns(), $entity->getValues(), "DocumentID",$entity->getId());
    }
    public function Insert(EntityWithID $entity) {
        DBContext::Instance()->InsertIntoTable("document",$entity->getColumns(),$entity->getValues());
    }
}